﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp16
{
    public class MainWindowViewModel : NotifyPropertyChangedBase
    {
   
        private EnumDataType _selectedEnumValue;
        public EnumDataType SelectedEnumValue
        {
            get { return _selectedEnumValue; }
            set
            {

                //_value = value;
                //RaisePropertyChanged();


                if (_selectedEnumValue != value)
                {
                    _selectedEnumValue = value;
                    RaisePropertyChanged();
                    // 根据类型重置Value
                    switch (value)
                    {
                        case EnumDataType.Float:
                            Value = 0f;
                            break;
                        case EnumDataType.Boolean:
                            Value = false;
                            break;
                        case EnumDataType.Integer:
                            Value = 0;
                            break;
                        case EnumDataType.String:
                            Value = string.Empty;
                            break;
                        case EnumDataType.Double:
                            Value = 0f;
                            break;
                        // 其他类型...
                        default:
                            Value = null;
                            break;
                    }
                }
            }

        }

        private object _value;
        public object Value
        {
            get { return _value; }
            set
            {
                _value = value;
                this.RaisePropertyChanged();
            }
        }

      


    }

    public class NotifyPropertyChangedBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public void RaisePropertyChanged([CallerMemberName] string propName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
        }
    }
}
